/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cn.tedu.luban.worker.protocol.query;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tedu.inn.protocol.pager.SimplePagerQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import lombok.Data;
import org.springframework.util.StringUtils;

@Data
public class WorkerListQuery extends SimplePagerQuery {
    @ApiModelProperty("师傅绑定userId")
    private String userId;
    @ApiModelProperty("师傅真实名称")
    private String realName;
    @ApiModelProperty("师傅手机号")
    private String phone;
    @ApiModelProperty("身份证号码")
    private String idCard;
    @ApiModelProperty("账号状态 0:锁定  1:正常")
    private Integer status;
    @ApiModelProperty("审核状态 0:驳回  1:通过  2:未审核")
    private List<Integer> auditStatus;
    @ApiModelProperty("开始日期")
    private String startDate;
    @ApiModelProperty("结束日期")
    private String endDate;
    public Long getStart() {
        if (StringUtils.isEmpty(startDate)) {
            return null;
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date start = sdf.parse(this.startDate);
            return start.getTime();
        } catch (ParseException e) {
            throw new RuntimeException("转化时间字符串失败");
        }
    }

    public Long getEnd() {
        if (StringUtils.isEmpty(endDate)) {
            return null;
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date end = sdf.parse(this.endDate);
            return end.getTime();
        } catch (ParseException e) {
            throw new RuntimeException("转化时间字符串失败");
        }
    }
}